package acwing._2LanQiao._2BinarySearch_PrefixSum;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._2BinarySearch_PrefixSum
 * @File : Q1230.java
 * @Author : WangRuoyu
 * @Date : 2023/3/14 14:06
 */

// 数组存储相同余数的边界数量
public class Q1230 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] words = line.split(" ");

        int n = Integer.parseInt(words[0]);
        int k = Integer.parseInt(words[1]);

        long[] s = new long[n + 1];
        int[] cnt = new int[k];
        cnt[0] = 1;
        long res = 0;
        int mod = 0;

        for (int i = 1; i <= n; ++i) {
            line = br.readLine();
            s[i] = Integer.parseInt(line) + s[i - 1];
            mod = (int) (s[i] % k);
            res += cnt[mod];
            cnt[mod]++;
        }
        System.out.println(res);
    }
}

// 暴力+前缀和 O(n2) 超时
//public class Q1230 {
//    public static void main(String[] args) throws IOException {
//        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        String line = br.readLine();
//        String[] words = line.split(" ");
//
//        int n = Integer.parseInt(words[0]);
//        int k = Integer.parseInt(words[1]);
//
//        int[] d = new int[n];
//        long[] s = new long[n + 1];
//
//        for (int i = 0; i < n; ++i) {
//            line = br.readLine();
//            d[i] = Integer.parseInt(line);
//        }
//
//        for (int i = 1; i <= n; ++i) {
//            s[i] = s[i - 1] + d[i - 1];
//        }
//
//        long res = 0;
//        for (int i = 0; i < n; ++i) {
//            for (int j = i; j < n; ++j) {
//                if ((s[j + 1] - s[i]) % k == 0) {
//                    res++;
//                }
//            }
//        }
//        System.out.println(res);
//    }
//}
//5 2
//1
//2
//3
//4
//5